import java.util.*;
import java.io.*;


public class group 
{
	private String name;
	private ArrayList<user> userList;
	
	public group(String nam)
	{
		userList = new ArrayList<user>();
		name = nam;
	}
	
	public void addUser(user o)
	{
		if (userList.size() == 0)
		{
			userList.add(o);
			return;
		}
			
		for (int i = 0; i < userList.size(); i++)
		{
			if (o.getName().compareTo(
					userList.get(i).getName()) > 0)
			{
				userList.add(i,o);
				return;
			}
		}
		userList.add(o);
	}
	
	public user findUser(String o)
	{
		int midpoint = userList.size()/2;
		while (true)
		{
			
			if (o.compareTo(
					userList.get(midpoint).getName()) == 0)
				return userList.get(midpoint);
			if (o.compareTo(
					userList.get(midpoint).getName()) < 0)
			{
				midpoint = midpoint/2;
			}
			if (midpoint == userList.size() - 1|| midpoint == 0 )
				return null;
			else
			{
				midpoint = midpoint + (int)((userList.size() - midpoint + .5)/2)  ;
			}
			
		}

		
	}
	
	public String toString()
	{
		String temp = "name: " + name;
		if (userList.size() == 0)
			return temp + " is empty";
		temp = temp + "Members: ";
		
		for (int i = 0; i < userList.size(); i++)
		{
			temp = temp + " " + userList.get(i).getName() + ",";
		}
		return temp;
	}

}
